Skip to content

Fix #225: allow disabling the RDP idle timeout (0 = never disconnect)#272

Open
eran132 wants to merge 1 commit into
Terminals-Origin:masterfrom
eran132:fix/225-rdp-idle-timeout-disable
Open

Fix #225: allow disabling the RDP idle timeout (0 = never disconnect)#272
eran132 wants to merge 1 commit into
Terminals-Origin:masterfrom
eran132:fix/225-rdp-idle-timeout-disable

Conversation

@eran132

@eran132 eran132 commented Jun 6, 2026

Copy link
Copy Markdown

Summary

Fixes #225. There was no way to stop RDP sessions from being disconnected for being idle — the idle timeout was clamped to 10–240, and entering 0 or -1 was silently forced back up to 10.

Root cause was a clamp in two places:

  • RdpTimeOutOptions.IdleTimeout clamped to [10, 240] on both get and set.
  • FavoriteConfigurationElement.IdleTimeout setter already allowed 0, but its getter forced any value < 10 up to 10 — so even a stored 0 read back as 10.

Change

Treat 0 as "disabled" in both layers, so it round-trips intact. It maps directly to the MsRdpClient control:

// RDPConnection.cs
this.client.AdvancedSettings2.MinutesToIdleTimeout = rdpOptions.TimeOuts.IdleTimeout;

MinutesToIdleTimeout = 0 means no idle timeout (documented MsRdpClient range is 0–240). Positive values are still clamped to [10, 240], so existing behavior is unchanged for them. I also aligned the config getter's upper bound to 240 (it was an inconsistent 600). The RDP Extended settings label now reads Idle Timeout (0=off) so the option is discoverable.

Tests

Added unit tests for both clamping layers (RdpTimeOutOptionsTests, plus cases in FavoriteConfigurationElementTests): 0 and -10, a positive value < 1010, > 240240, in-range preserved, default 240. Verified they fail before the change (0/-1 became 10) and pass after. Full suite shows no new failures (the only pre-existing failures locally are the SQL/LocalDB persistence tests, which need a database).

Note: I could not exercise an actual RDP session headlessly, so the MinutesToIdleTimeout = 0 "never disconnect" behavior relies on the documented MsRdpClient contract; the value is passed straight through unchanged.

🤖 Generated with Claude Code

The RDP idle timeout was clamped to 10-240, and the config layer's getter
forced any value below 10 up to 10, so entering 0 or -1 silently became 10.
Users running long-lived sessions had no way to stop idle disconnects.

Treat 0 as "disabled": RdpTimeOutOptions.IdleTimeout and
FavoriteConfigurationElement.IdleTimeout now allow 0 to round-trip (it maps
to MsRdpClient AdvancedSettings.MinutesToIdleTimeout = 0, i.e. no timeout).
Positive values are still clamped to the MsRdpClient range 10-240. Also
aligned the config getter's upper bound to 240 (was an inconsistent 600).
The RDP Extended settings label now reads "Idle Timeout (0=off)".

Adds unit tests for both clamping layers (0/-1 -> 0, <10 -> 10, >240 -> 240,
in-range preserved, default 240).

Fixes Terminals-Origin#225

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 6, 2026 09:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds support (and coverage) for disabling RDP idle timeout by allowing an IdleTimeout value of 0, while retaining clamping behavior for other values.

Changes:

  • Added a dedicated unit test suite for RdpTimeOutOptions idle-timeout normalization/clamping.
  • Updated RdpTimeOutOptions.IdleTimeout to preserve 0 as “disabled” and normalize negatives to 0.
  • Updated FavoriteConfigurationElement.IdleTimeout clamping behavior and added corresponding tests.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
Source/Tests/Tests.csproj Includes the new RdpTimeOutOptionsTests file in the test project build.
Source/Tests/Connections/RdpTimeOutOptionsTests.cs Adds coverage for IdleTimeout semantics (0 disable, negative normalize, min/max clamping).
Source/Tests/Configuration/FavoriteConfigurationElementTests.cs Adds tests validating config element IdleTimeout round-trip behavior, including the new “0 disables” rule.
Source/Terminals.Plugins.Rdp/RdpTimeOutOptions.cs Implements “0 disables idle timeout” and updates documentation accordingly.
Source/Terminals.Common/Configuration/FavoriteConfigurationElement.cs Adjusts config element clamping to allow 0 and clamp max to 240.
Files not reviewed (1)
  • Source/Terminals.Plugins.Rdp/RdpExtendedSettingsControl.Designer.cs: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 295 to 308
public Int32 IdleTimeout
{
get
{
Int32 val = (Int32)this["idleTimeout"];
if (val > 600)
val = 600;
if (val > 240)
val = 240;

if (val < 10)
val = 10;
// 0 means the idle timeout is disabled (never disconnect), so keep it as is.
if (val < 0)
val = 0;

return val;
}
Comment on lines +113 to +119
[TestMethod]
public void IdleTimeoutZero_SetGet_StaysZeroToDisableTimeout()
{
FavoriteConfigurationElement favorite = this.CreateFavorite();
favorite.IdleTimeout = 0;
Assert.AreEqual(0, favorite.IdleTimeout, "0 means the idle timeout is disabled and must survive a set/get round-trip (issue #225).");
}
Comment on lines 62 to 72
public Int32 IdleTimeout
{
get
{
return CorrectValueToInterval(10, 240, idleTimeout);
return idleTimeout <= 0 ? 0 : CorrectValueToInterval(10, 240, idleTimeout);
}
set
{
idleTimeout = CorrectValueToInterval(10, 240, value);
idleTimeout = value <= 0 ? 0 : CorrectValueToInterval(10, 240, value);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Add option to disable idle timeout

2 participants